package onem.soria.utils;

import onem.soria.entity.enums.ExceptionEnum;
import org.tinylog.Logger;

import java.io.File;

public class VerifyUtil {

    public static void verifyArgs(String[] args) {
        Logger.info("verifying args...");
        int len = args.length;
        if (len == 0) {
            ExceptionUtil.error(ExceptionEnum.NO_INPUT);
        }
        if (len > 2) {
            ExceptionUtil.error(ExceptionEnum.TO_MANY_ARGUMENTS);
        }
        File file = new File(args[0]);
        if (!file.exists()) {
            ExceptionUtil.error(ExceptionEnum.NOT_EXIST);
        }
        if(!file.getName().endsWith(".ncm")) {
            ExceptionUtil.error(ExceptionEnum.INCORRECT_EXTENSION);
        }
        Logger.info("args verification succeeded.");
    }

}
